package com.its.common.disruptor.use;

import com.its.common.disruptor.consumer.TimedAndMaxCountOnceMessageConsumer;
import com.its.common.disruptor.dto.TranslatorData;
import com.its.common.disruptor.dto.TranslatorDataWapper;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

/**
 * @Author xiaxp
 * @Date 2021-11-25 16:34
 * @Description
 */
@Slf4j
public class TimedAndMaxCountOnceMessageConsumerImpl extends TimedAndMaxCountOnceMessageConsumer {

	public TimedAndMaxCountOnceMessageConsumerImpl(String consumerId, int maxCount, long ms) {
		super(consumerId, maxCount, ms);
	}

	@Override
	public void handleDatasets(List<TranslatorDataWapper> list) {
		//TODO 业务处理逻辑: 数据库持久化操作 IO读写 ---> 交给一个线程池 去异步的调用执行 或者 可以考虑R2DBC

		for(TranslatorDataWapper wapper : list){
			TranslatorData req = wapper.getData();
		}

//		try {
//			Thread.sleep(ThreadLocalRandom.current().nextInt(1800));
//		} catch (InterruptedException e) {
//			e.printStackTrace();
//		}
	}

}
